<?php

use think\migration\Migrator;
use think\migration\db\Column;

class Admin extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $this->table('admin', ['collation' => 'utf8mb4_bin', 'comment' => '管理员表'])
            ->addColumn('username', 'string', ['null' => true, 'comment' => '用户名'])
            ->addColumn('password', 'string', ['default' => password_hash('123456', PASSWORD_DEFAULT), 'comment' => '密码'])
            ->addColumn('real_name', 'string', ['null' => true, 'comment' => '姓名'])
            ->addColumn('status', 'enum', ['values' => '1,2', 'default' => 1, 'comment' => '1正常；2禁用'])
            ->addColumn('create_time', 'integer', ['null' => true])
            ->addColumn('update_time', 'integer', ['null' => true])
            ->addColumn('delete_time', 'integer', ['null' => true])
            ->create();
    }
}
